package com.qing.thread.result;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.FutureTask;

/**
 * 线程的集中创建总结
 */
public class ResultThread {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        // extends Thread 启动方式
        new MyThread1().start();
        // implement Runnable 启动方式
        new Thread(new MyThread2()).start();
        // implement Callable 启动方式
        FutureTask futureTask = new FutureTask(new MyThread3());
        new Thread(futureTask).start();
        System.out.println(futureTask.get());
    }
}
class MyThread1 extends Thread{
    @Override
    public void run() {
        System.out.println("我是通过extends Thread创建出来的！");
    }
}
class MyThread2 implements Runnable{
    @Override
    public void run() {
        System.out.println("我是通过implement Runnable接口创建出来的！");
    }
}
class MyThread3 implements Callable{
    @Override
    public Integer call() throws Exception {
        System.out.println("我是通过implement Callable接口创建出来的！");
        System.out.println("lx和hwq99");
        return 99;
    }
}